package edu.unc.comp410.colemangeer.model.constraints;


public class StateAbbreviationConstraint extends StringConstraint {

	public StateAbbreviationConstraint(String theName, boolean theOptional) {
		super(theName, theOptional);
	}
	
	//TODO: override isLegal(), checking for correct - two letters, CAPS - abbreviations
	
	@Override
	public boolean isLegal(Object obj){
		String strValue;
		try{
			strValue = (String) obj;
		}
		catch(ClassCastException e){
			return false;
		}
		
		if (strValue.length()!=2)
			return false;
		
		for (Character c: strValue.toCharArray()){
			if (!Character.isUpperCase(c))
				return false;
		}
		
		return true;
	}
	

}
